

package c.x.jy.admin.config;

import java.net.DatagramSocket;
import java.net.SocketException;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override  
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
            .allowedOrigins("*")
            .allowCredentials(true)
            .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
            .maxAge(3600) 
        .allowCredentials(false).maxAge(3600);

    }
    
//    public static void main(String[] args) throws SocketException {
//        DatagramSocket d =new DatagramSocket(0) ;
//       System.out.println(  d.getLocalPort());
//	}
}